<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>v-on实例</title>
    <script src="../assets/js/vue.js"></script>
</head>
<body>
    <h1>v-on实例</h1>
    <hr/>
    <div id="app">
        本场比赛得分:{{score}}
        <p>
            <button @click="add">加分</button>
            <button @click="reduce">减分</button>
            <br>
            <input type="text" @keyup.enter="onEnter" v-model="addScore">
        </p>
    </div>

    <script>
        var app = new Vue({
            el: '#app',
            data: {
                score: 0,
                addScore: 1
            },
            methods:{
                add(){
                    this.score ++;
                },
                reduce(){
                    this.score --;
                },
                onEnter(){
                    this.score = Number.parseInt(this.score) + Number.parseInt(this.addScore);
                }
            }
        });
    </script>

</body>
</html>